Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

portal-vue

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

portal-vue

> A Portal Component for Vuejs, to render DOM outside of a component, anywhere in the document.

  • 2.1.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
506K
decreased by-1.87%
Maintainers
1
Weekly downloads
 
Created

What is portal-vue?

portal-vue is a Vue.js plugin that allows you to render a component's template in a different part of the DOM tree. This can be particularly useful for creating modals, tooltips, and other UI elements that need to be rendered outside of their parent component's DOM hierarchy.

What are portal-vue's main functionalities?

Basic Portal

This feature allows you to move a piece of the template to another part of the DOM. The `portal` component is used to specify the content to be moved and the `to` attribute specifies the target element.


<template>
  <div>
    <portal to="destination">
      <p>This content will be teleported to the destination element.</p>
    </portal>
    <div id="destination"></div>
  </div>
</template>

<script>
import { Portal } from 'portal-vue';

export default {
  components: {
    Portal
  }
};
</script>

Named Portals

Named portals allow you to manage multiple portals more easily by giving each portal a unique name.


<template>
  <div>
    <portal to="destination" name="example">
      <p>This content will be teleported to the destination element with a specific name.</p>
    </portal>
    <div id="destination"></div>
  </div>
</template>

<script>
import { Portal } from 'portal-vue';

export default {
  components: {
    Portal
  }
};
</script>

Scoped Slots

Scoped slots allow you to pass data from the parent component to the teleported content, making it more dynamic and interactive.


<template>
  <div>
    <portal to="destination" v-slot="props">
      <p>{{ props.message }}</p>
    </portal>
    <div id="destination"></div>
  </div>
</template>

<script>
import { Portal } from 'portal-vue';

export default {
  components: {
    Portal
  },
  data() {
    return {
      message: 'This is a scoped slot message.'
    };
  }
};
</script>

Other packages similar to portal-vue

FAQs

Package last updated on 28 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc